#include "NewBullet.h"

CNewBullet::CNewBullet()
{
	_alive = true;
	_countTime = GetTickCount();
	_x = -100;
	_y = -100;
	_timeaLive = 20;
	_vx = 0;
	_vy = 0;
	_BulletType = 0;
	_Sprite = CSpriteManager::getInstance()->GetObjectSprite(Object::Bullet);
}

void CNewBullet::SetNewBullet(float X, float Y, int TimeAlive, float vX, float vY, int BulletType)
{
	_alive = true;
	_countTime = GetTickCount();
	_x = X;
	_y = Y;
	_timeaLive = TimeAlive;
	_vx = vX;
	_vy = vY;
	_BulletType = BulletType;
}

void CNewBullet::Reset()
{
	_alive = true;
	_countTime = GetTickCount();
	_x = -100;
	_y = -100;
	_timeaLive = 20;
	_vx = 0;
	_vy = 0;
	_BulletType = 0;
}

bool CNewBullet::CheckALive()
{
	if (GetTickCount() - _countTime < _timeaLive)
	{
		return true;
	}

	_alive = false;
	return false;
}

void CNewBullet::Update()
{
	_x += _vx;
	_y += _vy;
}

void CNewBullet::Render()
{
	_Sprite->Render(_x, _y, _BulletType);
}

D3DXVECTOR2 CNewBullet::GetPostion()
{
	return D3DXVECTOR2(_x, _y);
}

CNewBullet::~CNewBullet()
{

}